package cn.k7g.virtual;

import cn.k7g.codeflow.annotation.NodeFlag;
import cn.k7g.codeflow.annotation.OutPort;
import cn.k7g.codeflow.invoke.CodeFlow;
import cn.k7g.codeflow.model.node.CodeNodeClass;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;


@Component
public class UserService implements CodeNodeClass {

    @NodeFlag(
            label = "获取用户信息",
            outPorts = {
                    @OutPort(name=CodeFlow.NAME_SUCCESS, type = User.class, remark = "成功"),
                    @OutPort(name=CodeFlow.NAME_ERROR, type = User.class, remark = "失败")
            }
    )
    public static void getUser(CodeFlow flow) {
        try {
            flow.out(CodeFlow.NAME_SUCCESS, new User());
        } catch (Exception e) {
            flow.out(CodeFlow.NAME_ERROR, new User());
        }
    }
    @NodeFlag(
            label = "获取用户信息",
            outPorts = {
                    @OutPort(name=CodeFlow.NAME_SUCCESS, type = User.class, remark = "成功"),
                    @OutPort(name=CodeFlow.NAME_ERROR, type = User.class, remark = "失败")
            }
    )
    public static void getUser(CodeFlow flow, String a , int b, Integer c) {

    }
    public static void main(String[] args) {
        for (Method method : UserService.class.getMethods()) {
            System.out.println(method.toString());
        }
    }
}
